<?php

/**
 * @author SNOWTAM
 * @purpose Graph of voltage by time with flash graph component.       
 * @created 2008-12-17
 */

	require("config/db_config.php");
	$connection = mysql_connect($db_host, $db_user, $db_password) or die("Unable to connect");
	mysql_select_db($db_name, $connection);

//start the XML output 
print "<chart>";
print "<chart_type>area</chart_type>";
print "<axis_category size='9' alpha='75' orientation='vertical_down' margin='false' />";
print "<axis_ticks value_ticks='false' category_ticks='false' major_thickness='1' minor_thickness='0' minor_count='1' major_color='000000' minor_color='222222' position='inside' />";
print "<axis_value min='6' max='7' size='10' color='ffffff' alpha='60' prefix='' suffix='' decimals='0' separator='' show_min='false' />";
print "<chart_rect x='75' y='75' width='300' height='180' positive_color='000000' positive_alpha='25' corner_tl='0' corner_tr='75' corner_br='0' corner_bl='0' />";
print "<legend  shadow='low' x='75' y='30' width='10' height='35' margin='20' fill_color='ffffff' fill_alpha='0' line_color='000000' line_alpha='0' line_thickness='0' layout='vertical' size='12' color='ffffff' alpha='75' />";
print "<chart_transition type='slide_right' delay='0' duration='.5' order='series' />";
print "<chart_data>";

//output the first row that contains the years 
print "<row>";
print "<null/>";
$lvs_query = "select * from weather_bat where (hour(date_stamp)=15 AND minute(date_stamp)=0) OR (hour(date_stamp)=6 AND minute(date_stamp)=0) ORDER BY date_stamp DESC LIMIT 20";

$result = mysql_query($lvs_query);
	for ( $i=0; $i < mysql_num_rows($result); $i++ ) 
		{
			print "<string>".mysql_result( $result, $i, 0)."</string>";
		}
print "</row>";

print "<row>";
print "<string>Battery Voltage</string>"; 

	for ($i=0; $i < mysql_num_rows($result); $i++)
	{
		$tooltip = mysql_result($result, $i, 1);
		print "<number tooltip='$tooltip'>".mysql_result($result, $i, 1)."</number>";	
		
	}
print "</row>";

//finish the XML output 
print "</chart_data>";
print "<chart_guide radius='6' line_color='ff4400' line_alpha='90' line_thickness='2' />";
print "<chart_pref point_size='7' trend_alpha='20' trend_thickness='2' />";
print "</chart>";

?>